<?php

/**
 * @author Ismael Gonzalez
 * @copyright 2012
 */

class asiLoTwiteo{
	public function addAsiLoTwiteo($autor, $texto){
		$autor = htmlentities(str_replace("@", "", $autor), ENT_COMPAT, 'UTF-8');
		$texto = htmlentities($texto,ENT_COMPAT, 'UTF-8');
		
		$SQL = "INSERT INTO asilotwiteo (autor, texto, fecha_creado, creado_por) VALUES ('".$autor."', '".$texto."', 
		'".date('Y-m-d H:i:s')."', ".$_SESSION["AdminID"]." )";
		$Q = mysql_query($SQL)or die(mysql_error());
	}
	
	public function getAsiLoTwiteo20(){
		$SQL = "SELECT * FROM asilotwiteo ORDER BY fecha_creado DESC LIMIT 20";
		$Q = mysql_query($SQL)or die(mysql_error());
		
		$i = 0;
		$arrResults = Array();
		while($row = mysql_fetch_array($Q)){
			$arrResults[$i]["id"]= $row["id"];
			$arrResults[$i]["autor"]= $row["autor"];
			$arrResults[$i]["texto"]= $row["texto"];
			$arrResults[$i]["status"]= $row["status"];
			$i++;
		}
		
		return $arrResults;
	}
	
	public function editAsiLoTwiteo($autor, $texto, $id){
		$autor = htmlentities($autor, ENT_COMPAT, 'UTF-8');
		$texto = htmlentities($texto, ENT_COMPAT, 'UTF-8');
		
		$SQL = "UPDATE asilotwiteo set autor='".$autor."', texto='".$texto."', status='".$status."' WHERE id = ".$id;
		$Q = mysql_query($SQL)or die(mysql_error());
	}
	
	public function getAsiLoTwiteo($id){
		$SQL = "SELECT * FROM asilotwiteo WHERE id = ".$id;
		$Q = mysql_query($SQL)or die(mysql_error());
		$row = mysql_fetch_array($Q);
		
		return $row;
	}
}

?>